#include <curses.h>

char *map[]={
	"***************",
	"*      *      *",
	"*             *",
	"*      *** ****",
	"**** ***   *  *",
	"*          *  *",
	"*          *  *",
	"*             *",
	"*          *  *",
	"***************"
};

main() {
	//initialize curses
	keypad(initscr(),1);
	
	//player's starting coordinates 
	int y=1;
	int x=1;
	
	//last key pressed
	int c;
	do {
		//draw map
		for (int yy=0;yy<10;yy++)
			for (int xx=0;xx<15;xx++)
				mvaddch(yy,xx,map[yy][xx]);
		
		//move player if there is no wall on the way
		if (KEY_UP==c && ' '==map[y-1][x])
			y--;
		if (KEY_DOWN==c && ' '==map[y+1][x])
			y++;
		if (KEY_LEFT==c && ' '==map[y][x-1])
			x--;
		if (KEY_RIGHT==c && ' '==map[y][x+1])
			x++;
		
		//draw player
		mvaddch(y,x,'@');
	//quit when 'q' is pressed
	} while((27!=(c=getch())));
	
	//clean up after we've finished using curses
	endwin();
}

